/*
 * AsistenteBienvenida.java
 *
 * Created on 30 de septiembre de 2005, 11:06 AM
 */

package com.ig.presentacion.escritorio.asistente;
import com.ig.presentacion.interfaces.comunes.IModelo;
import com.ig.presentacion.modelos.asistente.MDialogoComun;


import java.awt.Dimension;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

/**
 *
 * @author  jsanchez
 */
public class DAsistente extends javax.swing.JInternalFrame{
    static final long serialVersionUID=0; 
    private IModelo modelo;
    /** Creates new form AsistenteBienvenida */
    public DAsistente(/*java.awt.Frame parent, boolean modal, */IModelo modelo){
        super("Modelos",true,false,true,true);
        this.modelo=modelo;        
        initComponents();
        this.setTitle(modelo.getTitle());
        this.labelVisibles(modelo.getNumeroDialogos());
        this.activarBotones(false,true,false,true);
        if(!modelo.isDialogo_bienvenida()){
           this.Label_Bienvenida.setVisible(false);
           this.siguiente();
        }
        //dialogo.setSize(getWidth()+50,getHeight()+50);
        this.Panel_trabajo.updateUI();
        this.pack();
    }
    
    /**
     *Evento para cuando el usuario hace click en el boton anterior del asistente
     *
     */
    private void anterior(){
        modelo.setSecuencia(modelo.getSecuencia()-1);
        if(modelo.getSecuencia().equals(0)){
                this.Panel_trabajo.removeAll();
                org.jdesktop.layout.GroupLayout Panel_trabajoLayout = new org.jdesktop.layout.GroupLayout(Panel_trabajo);
                Panel_trabajo.setLayout(Panel_trabajoLayout);
                Panel_trabajoLayout.setHorizontalGroup(
                    Panel_trabajoLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(Panel_trabajoLayout.createSequentialGroup()
                        .addContainerGap()
                        .add(jScrollPane1, org.jdesktop.layout.GroupLayout.TRAILING, 243, Short.MAX_VALUE)
                        .addContainerGap())
                );
                Panel_trabajoLayout.setVerticalGroup(
                    Panel_trabajoLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(Panel_trabajoLayout.createSequentialGroup()
                        .addContainerGap()
                        .add(jScrollPane1, org.jdesktop.layout.GroupLayout.TRAILING, 125, Short.MAX_VALUE)
                        .addContainerGap())
                );
        }
        validarPaso();
        this.updateUI();        
    }
    /**
     *administra el panel de trabajo donde se adicionaran los paneles que cosrresponde a cada negocio.
     *@param  JPanel panel: es el panel que que sera adicionado al panel de trabajo
     */
    public void panelTrabajoLayout(JPanel panel){        
        Panel_trabajo.removeAll();
        org.jdesktop.layout.GroupLayout Panel_trabajoLayout = new org.jdesktop.layout.GroupLayout(Panel_trabajo);        
        Panel_trabajoLayout.setHorizontalGroup(
            Panel_trabajoLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, Panel_trabajoLayout.createSequentialGroup()
                .addContainerGap()
                .add(panel)//, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        Panel_trabajoLayout.setVerticalGroup(
            Panel_trabajoLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, Panel_trabajoLayout.createSequentialGroup()
                .addContainerGap()
                .add(panel)//, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        Panel_trabajo.setLayout(Panel_trabajoLayout);
        Panel_trabajo.updateUI();
    } 
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        jPanel1 = new javax.swing.JPanel();
        jSeparator1 = new javax.swing.JSeparator();
        Label_Pasos = new javax.swing.JLabel();
        Label_1 = new javax.swing.JLabel();
        Label_2 = new javax.swing.JLabel();
        Label_3 = new javax.swing.JLabel();
        Label_4 = new javax.swing.JLabel();
        Label_5 = new javax.swing.JLabel();
        Label_6 = new javax.swing.JLabel();
        Label_Bienvenida = new javax.swing.JLabel();
        Label_7 = new javax.swing.JLabel();
        Label_8 = new javax.swing.JLabel();
        jSeparator2 = new javax.swing.JSeparator();
        Button_Cancelar = new javax.swing.JButton();
        Button_Finalizar = new javax.swing.JButton();
        Button_Siguiente = new javax.swing.JButton();
        Button_Anterior = new javax.swing.JButton();
        Label_operacion = new javax.swing.JLabel();
        jSeparator3 = new javax.swing.JSeparator();
        Panel_trabajo = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        Text_Bienvenida = new javax.swing.JTextPane();
        jToolBar1 = new javax.swing.JToolBar();
        Nuevo = new javax.swing.JButton();
        Buscar = new javax.swing.JButton();
        Editar = new javax.swing.JButton();
        Guardar = new javax.swing.JButton();
        Eliminar = new javax.swing.JButton();
        Cancelar = new javax.swing.JButton();
        Salir = new javax.swing.JButton();

        setFrameIcon(new javax.swing.ImageIcon("lib/images/metrica.gif"));
        jPanel1.setBackground(new java.awt.Color(255, 255, 255));

        Label_Pasos.setText("Pasos");

        Label_1.setBackground(new java.awt.Color(255, 255, 255));
        Label_1.setFont(new java.awt.Font("Dialog", 0, 10));
        Label_1.setText(modelo.getLabel1());
        Label_1.setName("1");
        Label_1.setOpaque(true);
        Label_1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                Label_1MouseClicked(evt);
            }
        });

        Label_2.setBackground(new java.awt.Color(255, 255, 255));
        Label_2.setFont(new java.awt.Font("Dialog", 0, 10));
        Label_2.setText(modelo.getLabel2());
        Label_2.setName("2");
        Label_2.setOpaque(true);
        Label_2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                Label_2MouseClicked(evt);
            }
        });

        Label_3.setBackground(new java.awt.Color(255, 255, 255));
        Label_3.setFont(new java.awt.Font("Dialog", 0, 10));
        Label_3.setText(modelo.getLabel3());
        Label_3.setName("3");
        Label_3.setOpaque(true);
        Label_3.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                Label_3MouseClicked(evt);
            }
        });

        Label_4.setBackground(new java.awt.Color(255, 255, 255));
        Label_4.setFont(new java.awt.Font("Dialog", 0, 10));
        Label_4.setText(modelo.getLabel4());
        Label_4.setName("4");
        Label_4.setOpaque(true);
        Label_4.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                Label_4MouseClicked(evt);
            }
        });

        Label_5.setBackground(new java.awt.Color(255, 255, 255));
        Label_5.setFont(new java.awt.Font("Dialog", 0, 10));
        Label_5.setText(modelo.getLabel5());
        Label_5.setName("5");
        Label_5.setOpaque(true);
        Label_5.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                Label_5MouseClicked(evt);
            }
        });

        Label_6.setBackground(new java.awt.Color(255, 255, 255));
        Label_6.setFont(new java.awt.Font("Dialog", 0, 10));
        Label_6.setText(modelo.getLabel6());
        Label_6.setName("6");
        Label_6.setOpaque(true);
        Label_6.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                Label_6MouseClicked(evt);
            }
        });

        Label_Bienvenida.setBackground(new java.awt.Color(255, 255, 255));
        Label_Bienvenida.setFont(new java.awt.Font("Dialog", 0, 10));
        Label_Bienvenida.setText(modelo.getLabelBienvenida());
        Label_Bienvenida.setName("0");
        Label_Bienvenida.setOpaque(true);
        Label_1.setVisible(false);         Label_2.setVisible(false);         Label_3.setVisible(false);         Label_4.setVisible(false);         Label_5.setVisible(false);         Label_6.setVisible(false);         Label_7.setVisible(false);         Label_8.setVisible(false);
        Label_Bienvenida.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                Label_BienvenidaMouseClicked(evt);
            }
        });

        Label_7.setBackground(new java.awt.Color(255, 255, 255));
        Label_7.setFont(new java.awt.Font("Dialog", 0, 10));
        Label_7.setText(modelo.getLabel7());
        Label_7.setName("7");
        Label_7.setOpaque(true);
        Label_7.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                Label_7MouseClicked(evt);
            }
        });

        Label_8.setBackground(new java.awt.Color(255, 255, 255));
        Label_8.setFont(new java.awt.Font("Dialog", 0, 10));
        Label_8.setText(modelo.getLabel8());
        Label_8.setName("8");
        Label_8.setOpaque(true);
        Label_8.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                Label_8MouseClicked(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                        .add(jSeparator1)
                        .add(Label_Pasos)
                        .add(Label_Bienvenida)
                        .add(Label_1)
                        .add(Label_2)
                        .add(Label_3)
                        .add(Label_4)
                        .add(Label_5)
                        .add(Label_6))
                    .add(Label_7)
                    .add(Label_8))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .add(6, 6, 6)
                .add(Label_Pasos)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jSeparator1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(Label_Bienvenida)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(Label_1)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(Label_2)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(Label_3)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(Label_4)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(Label_5)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(Label_6)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(Label_7)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(Label_8)
                .addContainerGap(20, Short.MAX_VALUE))
        );

        Button_Cancelar.setFont(new java.awt.Font("Dialog", 1, 10));
        Button_Cancelar.setText("Salir");
        Button_Cancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Button_CancelarActionPerformed(evt);
            }
        });
        Button_Cancelar.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                Button_CancelarKeyPressed(evt);
            }
        });

        Button_Finalizar.setFont(new java.awt.Font("Dialog", 1, 10));
        Button_Finalizar.setText("Finalizar");
        Button_Finalizar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Button_FinalizarActionPerformed(evt);
            }
        });
        Button_Finalizar.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                Button_FinalizarKeyPressed(evt);
            }
        });

        Button_Siguiente.setFont(new java.awt.Font("Dialog", 1, 10));
        Button_Siguiente.setText("Siguiente");
        Button_Siguiente.setSelected(true);
        Button_Siguiente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Button_SiguienteActionPerformed(evt);
            }
        });
        Button_Siguiente.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                Button_SiguienteKeyPressed(evt);
            }
        });

        Button_Anterior.setFont(new java.awt.Font("Dialog", 1, 10));
        Button_Anterior.setText("Anterior");
        Button_Anterior.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Button_AnteriorActionPerformed(evt);
            }
        });
        Button_Anterior.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                Button_AnteriorKeyPressed(evt);
            }
        });

        Label_operacion.setText(modelo.getLabelBienvenida());

        Panel_trabajo.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        Panel_trabajo.setPreferredSize(new Dimension(modelo.getWidth(),modelo.getHeight()));
        jScrollPane1.setBorder(null);
        Text_Bienvenida.setBackground(new java.awt.Color(238, 238, 238));
        Text_Bienvenida.setBorder(null);
        Text_Bienvenida.setEditable(false);
        Text_Bienvenida.setFont(new java.awt.Font("Dialog", 0, 10));
        Text_Bienvenida.setText(modelo.getBienvenida());
        jScrollPane1.setViewportView(Text_Bienvenida);

        org.jdesktop.layout.GroupLayout Panel_trabajoLayout = new org.jdesktop.layout.GroupLayout(Panel_trabajo);
        Panel_trabajo.setLayout(Panel_trabajoLayout);
        Panel_trabajoLayout.setHorizontalGroup(
            Panel_trabajoLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(Panel_trabajoLayout.createSequentialGroup()
                .addContainerGap()
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 403, Short.MAX_VALUE)
                .addContainerGap())
        );
        Panel_trabajoLayout.setVerticalGroup(
            Panel_trabajoLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, Panel_trabajoLayout.createSequentialGroup()
                .addContainerGap()
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 110, Short.MAX_VALUE)
                .addContainerGap())
        );

        jToolBar1.setEnabled(false);
        Nuevo.setIcon(new javax.swing.ImageIcon("lib/images/nuevo.gif"));
        Nuevo.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 5, 1, 5));
        Nuevo.setOpaque(false);
        Nuevo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                NuevoActionPerformed(evt);
            }
        });

        jToolBar1.add(Nuevo);

        Buscar.setIcon(new javax.swing.ImageIcon("lib/images/buscar.gif"));
        Buscar.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 5, 1, 5));
        Buscar.setOpaque(false);
        Buscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BuscarActionPerformed(evt);
            }
        });

        jToolBar1.add(Buscar);

        Editar.setIcon(new javax.swing.ImageIcon("lib/images/editar.gif"));
        Editar.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 5, 1, 5));
        Editar.setOpaque(false);
        Editar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                EditarActionPerformed(evt);
            }
        });

        jToolBar1.add(Editar);

        Guardar.setIcon(new javax.swing.ImageIcon("lib/images/guardar.gif"));
        Guardar.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 5, 1, 5));
        Guardar.setOpaque(false);
        Guardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                GuardarActionPerformed(evt);
            }
        });

        jToolBar1.add(Guardar);

        Eliminar.setIcon(new javax.swing.ImageIcon("lib/images/borrar.gif"));
        Eliminar.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 5, 1, 5));
        Eliminar.setOpaque(false);
        Eliminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                EliminarActionPerformed(evt);
            }
        });

        jToolBar1.add(Eliminar);

        Cancelar.setIcon(new javax.swing.ImageIcon("lib/images/cancelar.gif"));
        Cancelar.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 5, 1, 5));
        Cancelar.setOpaque(false);
        Cancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CancelarActionPerformed(evt);
            }
        });

        jToolBar1.add(Cancelar);

        Salir.setIcon(new javax.swing.ImageIcon("lib/images/salir.gif"));
        Salir.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 5, 1, 5));
        Salir.setOpaque(false);
        Salir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SalirActionPerformed(evt);
            }
        });

        jToolBar1.add(Salir);

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jSeparator2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 533, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                        .addContainerGap(203, Short.MAX_VALUE)
                        .add(Button_Anterior)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(Button_Siguiente)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(Button_Finalizar)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(Button_Cancelar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 73, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED))
                    .add(layout.createSequentialGroup()
                        .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                            .add(Panel_trabajo, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .add(org.jdesktop.layout.GroupLayout.LEADING, jToolBar1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 431, Short.MAX_VALUE)
                            .add(org.jdesktop.layout.GroupLayout.LEADING, jSeparator3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 431, Short.MAX_VALUE)
                            .add(org.jdesktop.layout.GroupLayout.LEADING, Label_operacion))))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(layout.createSequentialGroup()
                        .add(6, 6, 6)
                        .add(Label_operacion)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jSeparator3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jToolBar1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(Panel_trabajo, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jSeparator2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 15, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(3, 3, 3)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(Button_Finalizar)
                    .add(Button_Siguiente)
                    .add(Button_Anterior)
                    .add(Button_Cancelar))
                .addContainerGap())
        );
        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void SalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SalirActionPerformed
        if(Salir.isEnabled()){
            Salir.setEnabled(false);
            this.modelo.Salir();
        }
    }//GEN-LAST:event_SalirActionPerformed

    private void CancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CancelarActionPerformed
        if(Cancelar.isEnabled()){
            Cancelar.setEnabled(false);
            modelo.Cancelar();
        }
    }//GEN-LAST:event_CancelarActionPerformed

    private void EliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_EliminarActionPerformed
        if(Eliminar.isEnabled()){
            Eliminar.setEnabled(false);
            modelo.Eliminar();
        }
    }//GEN-LAST:event_EliminarActionPerformed

    private void GuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_GuardarActionPerformed
        if(Guardar.isEnabled()){
            Guardar.setEnabled(false);
            modelo.Guardar();
        }
    }//GEN-LAST:event_GuardarActionPerformed

    private void EditarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_EditarActionPerformed
        if(Editar.isEnabled()){
            Editar.setEnabled(false);
            modelo.Editar();
        }
    }//GEN-LAST:event_EditarActionPerformed

    private void BuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BuscarActionPerformed
        if(Buscar.isEnabled()){
            Buscar.setEnabled(false);
            modelo.Buscar();
        }
    }//GEN-LAST:event_BuscarActionPerformed

    private void NuevoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NuevoActionPerformed
        if(Nuevo.isEnabled()){
            Nuevo.setEnabled(false);
            modelo.Nuevo();
        }
    }//GEN-LAST:event_NuevoActionPerformed
    
    public void setEstadoBotones(boolean nuevo,boolean buscar,boolean editar,boolean guardar,boolean eliminar,boolean cancelar,boolean salir){
        this.Nuevo.setEnabled(nuevo);
        this.Buscar.setEnabled(buscar);
        this.Editar.setEnabled(editar);
        this.Guardar.setEnabled(guardar);
        this.Eliminar.setEnabled(eliminar);
        this.Cancelar.setEnabled(cancelar);
        this.Salir.setEnabled(salir);       
    }
    private void validaClicked(int quien){
        Integer i=modelo.getSecuencia();        
        if(modelo.getSecuencia()>quien){
            while(modelo.getSecuencia()>quien){
                this.anterior();
            }
        }else{
            while(modelo.getSecuencia()<quien){
                this.siguiente();
            }            
        }
    }
    
    private void Label_8MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_Label_8MouseClicked
        validaClicked(Integer.valueOf(Label_8.getName()));
    }//GEN-LAST:event_Label_8MouseClicked

    private void Label_7MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_Label_7MouseClicked
        validaClicked(Integer.valueOf(Label_7.getName()));
    }//GEN-LAST:event_Label_7MouseClicked

    private void Label_6MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_Label_6MouseClicked
        validaClicked(Integer.valueOf(Label_6.getName()));
    }//GEN-LAST:event_Label_6MouseClicked

    private void Label_5MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_Label_5MouseClicked
        validaClicked(Integer.valueOf(Label_5.getName()));
    }//GEN-LAST:event_Label_5MouseClicked

    private void Label_4MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_Label_4MouseClicked
        validaClicked(Integer.valueOf(Label_4.getName()));
    }//GEN-LAST:event_Label_4MouseClicked

    private void Label_3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_Label_3MouseClicked
        validaClicked(Integer.valueOf(Label_3.getName()));
    }//GEN-LAST:event_Label_3MouseClicked

    private void Label_2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_Label_2MouseClicked
        validaClicked(Integer.valueOf(Label_2.getName()));
    }//GEN-LAST:event_Label_2MouseClicked

    private void Label_1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_Label_1MouseClicked
        validaClicked(Integer.valueOf(Label_1.getName()));
    }//GEN-LAST:event_Label_1MouseClicked

    private void Label_BienvenidaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_Label_BienvenidaMouseClicked
        validaClicked(Integer.valueOf(Label_Bienvenida.getName()));
    }//GEN-LAST:event_Label_BienvenidaMouseClicked

    private void Button_CancelarKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_Button_CancelarKeyPressed
            if(evt.getKeyCode()==10)cancelar();
    }//GEN-LAST:event_Button_CancelarKeyPressed

    private void Button_FinalizarKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_Button_FinalizarKeyPressed
            if(evt.getKeyCode()==10)this.modelo.finalizar(this);
    }//GEN-LAST:event_Button_FinalizarKeyPressed

    private void Button_SiguienteKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_Button_SiguienteKeyPressed
        if(evt.getKeyCode()==10)siguiente();
    }//GEN-LAST:event_Button_SiguienteKeyPressed

    private void Button_AnteriorKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_Button_AnteriorKeyPressed
// TODO add your handling code here:
        if(evt.getKeyCode()==10)
            anterior();        
    }//GEN-LAST:event_Button_AnteriorKeyPressed
    private void cancelar(){
        if(JOptionPane.showConfirmDialog(this,"Desea cerrar el asistente para:\n"+this.modelo.getTitle(),"Mensaje",JOptionPane.OK_CANCEL_OPTION)==0){
            this.dispose();
        }    
    }
    private void Button_CancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Button_CancelarActionPerformed
            cancelar();
    }//GEN-LAST:event_Button_CancelarActionPerformed

    private void Button_FinalizarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Button_FinalizarActionPerformed
        //modelo.getADAsistente dialogo=(DAsistente)obj;    
        if(JOptionPane.showInternalConfirmDialog(this,"Desea generar informa para Imprimir","Confirmaci\u00f3n",JOptionPane.OK_CANCEL_OPTION)==0){
            ((MDialogoComun)modelo).previewInforme(this.modelo.getObject());
        }
        this.modelo.finalizar(this);
    }//GEN-LAST:event_Button_FinalizarActionPerformed
    /**
     *verifica por que numero de paso de 6 esta el asistente.
     *dependiendo del paso le notifica al modelo del negocio que paso debe ejecutar, cada modelo debe
     * implementar la interface IModelo.
     *
     */
    private void validarPaso(){
        int a=modelo.getNumeroDialogos();
        int b=modelo.getSecuencia();
        //System.out.println(":::"+a+":::"+b);
        if(a==b){            
            activarBotones(true,false,true,true);
        }else if(a>b){
            activarBotones(true,true,false,true);
        }            
        //pasoOfpasos.setText(modelo.getSecuencia()+" de "+modelo.getNumeroDialogos());
        if(modelo.getSecuencia().equals(0)){            
            activarBotones(false,true,false,true);
            modelo.paso0();                                    
            //this.Button_Anterior.setEnabled(false);
        }else if(modelo.getSecuencia().equals(1)){
            modelo.paso1();
            panelTrabajoLayout(modelo.getPanel1());            
        }else if(modelo.getSecuencia().equals(2)){            
            modelo.paso2();
            panelTrabajoLayout(modelo.getPanel2());
        }else if(modelo.getSecuencia().equals(3)){
            modelo.paso3();
            panelTrabajoLayout(modelo.getPanel3());
        }else if(modelo.getSecuencia().equals(4)){
            modelo.paso4();
            panelTrabajoLayout(modelo.getPanel4());            
        }else if(modelo.getSecuencia().equals(5)){
            modelo.paso5();
            panelTrabajoLayout(modelo.getPanel5());
        }else if(modelo.getSecuencia().equals(6)){
            modelo.paso6();
            panelTrabajoLayout(modelo.getPanel6());
        }else if(modelo.getSecuencia().equals(7)){
            modelo.paso7();
            panelTrabajoLayout(modelo.getPanel7());
        }else if(modelo.getSecuencia().equals(8)){
            modelo.paso8();
            panelTrabajoLayout(modelo.getPanel8());
        }                
        
    }
    
    /**
     *  Evento que se ejecuta cuando el usuario hace cllick en el botton siquiente de el asistente.
     *
     */
    private void siguiente(){
        this.activarBotones(false,false,false,false);
        if(((MDialogoComun)modelo).getDialogo()==null) 
            ((MDialogoComun)modelo).setDialogo(this);
        modelo.setSecuencia(modelo.getSecuencia()+1);        
        validarPaso();
        this.updateUI();
    }
    
    private void Button_SiguienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Button_SiguienteActionPerformed
        siguiente();
    }//GEN-LAST:event_Button_SiguienteActionPerformed

    private void Button_AnteriorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Button_AnteriorActionPerformed
        anterior();
    }//GEN-LAST:event_Button_AnteriorActionPerformed
    
    /**     
     *metodo que activa, desactiva, y cambia de colores de los label's que indican el proceso en el que esta el asistente
     *     
     * @param   boolean Anterior    
     * @param   boolean Siguiente
     * @param   boolean Finalizar
     * @param   boolean Cancelar
     *
     */
    public void activarBotones(boolean Anterior,boolean Siguiente,boolean Finalizar,boolean Cancelar){
        Button_Anterior.setEnabled(Anterior);
        Button_Siguiente.setEnabled(Siguiente);
        Button_Finalizar.setEnabled(Finalizar);
        Button_Cancelar.setEnabled(Cancelar);
        cambiarColorLabes();
    }
    /**
     * hace visibles label's dependiendo del atributo optenido desde el archivo de propiedades
     */
    private void labelVisibles(Integer numeroLabel){  
        //System.out.println("-->"+numeroLabel);
        if(numeroLabel.equals(1)){
            Label_1.setVisible(true);
        }else if(numeroLabel.equals(2)){
            Label_1.setVisible(true);
            Label_2.setVisible(true);
        }else if(numeroLabel.equals(3)){
            Label_1.setVisible(true);
            Label_2.setVisible(true);
            Label_3.setVisible(true);
        }else if(numeroLabel.equals(4)){
            Label_1.setVisible(true);
            Label_2.setVisible(true);
            Label_3.setVisible(true);
            Label_4.setVisible(true);
        }else if(numeroLabel.equals(5)){
            Label_1.setVisible(true);
            Label_2.setVisible(true);
            Label_3.setVisible(true);
            Label_4.setVisible(true);
            Label_5.setVisible(true);
        }else if(numeroLabel.equals(6)){
            Label_1.setVisible(true);
            Label_2.setVisible(true);
            Label_3.setVisible(true);
            Label_4.setVisible(true);
            Label_5.setVisible(true);
            Label_6.setVisible(true);
        }else if(numeroLabel.equals(7)){
            Label_1.setVisible(true);
            Label_2.setVisible(true);
            Label_3.setVisible(true);
            Label_4.setVisible(true);
            Label_5.setVisible(true);
            Label_6.setVisible(true);            
            Label_7.setVisible(true);
        }else if(numeroLabel.equals(8)){
            Label_1.setVisible(true);
            Label_2.setVisible(true);
            Label_3.setVisible(true);
            Label_4.setVisible(true);
            Label_5.setVisible(true);
            Label_6.setVisible(true);            
            Label_7.setVisible(true);
            Label_8.setVisible(true);
        }            
    }
    /**
     *cambia los colores de los label's dependiendo del paso en que este la asistente
     */
    private void cambiarColorLabes(){        
        this.Label_Bienvenida.setBackground(new java.awt.Color(255,255,255));
        this.Label_1.setBackground(new java.awt.Color(255,255,255));
        this.Label_2.setBackground(new java.awt.Color(255,255,255));
        this.Label_3.setBackground(new java.awt.Color(255,255,255));
        this.Label_4.setBackground(new java.awt.Color(255,255,255));
        this.Label_5.setBackground(new java.awt.Color(255,255,255));
        this.Label_6.setBackground(new java.awt.Color(255,255,255));
        this.Label_7.setBackground(new java.awt.Color(255,255,255));
        this.Label_8.setBackground(new java.awt.Color(255,255,255));        
        
        if(modelo.getSecuencia().equals(0)){ this.Label_Bienvenida.setBackground(new java.awt.Color(204,204,255)); this.Label_operacion.setText(Label_Bienvenida.getText());}
        else if(modelo.getSecuencia().equals(1)){ this.Label_1.setBackground(new java.awt.Color(204,204,255)); this.Label_operacion.setText(Label_1.getText());}
        else if(modelo.getSecuencia().equals(2)){ this.Label_2.setBackground(new java.awt.Color(204,204,255)); this.Label_operacion.setText(Label_2.getText());}
        else if(modelo.getSecuencia().equals(3)){ this.Label_3.setBackground(new java.awt.Color(204,204,255)); this.Label_operacion.setText(Label_3.getText());}
        else if(modelo.getSecuencia().equals(4)){ this.Label_4.setBackground(new java.awt.Color(204,204,255)); this.Label_operacion.setText(Label_4.getText());}
        else if(modelo.getSecuencia().equals(5)){ this.Label_5.setBackground(new java.awt.Color(204,204,255)); this.Label_operacion.setText(Label_5.getText());}
        else if(modelo.getSecuencia().equals(6)){ this.Label_6.setBackground(new java.awt.Color(204,204,255)); this.Label_operacion.setText(Label_6.getText());}
        else if(modelo.getSecuencia().equals(7)){ this.Label_7.setBackground(new java.awt.Color(204,204,255)); this.Label_operacion.setText(Label_7.getText());}
        else if(modelo.getSecuencia().equals(8)){ this.Label_8.setBackground(new java.awt.Color(204,204,255)); this.Label_operacion.setText(Label_8.getText());}        
    }

    public void setEnableToolBar(boolean b) {
        this.Editar.setEnabled(b);
        this.Eliminar.setEnabled(b);
        this.Buscar.setEnabled(b);
        this.Guardar.setEnabled(b);
        this.Salir.setEnabled(b);
        this.Cancelar.setEnabled(b);
        this.Nuevo.setEnabled(b);
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Buscar;
    private javax.swing.JButton Button_Anterior;
    private javax.swing.JButton Button_Cancelar;
    private javax.swing.JButton Button_Finalizar;
    private javax.swing.JButton Button_Siguiente;
    private javax.swing.JButton Cancelar;
    private javax.swing.JButton Editar;
    private javax.swing.JButton Eliminar;
    private javax.swing.JButton Guardar;
    private javax.swing.JLabel Label_1;
    private javax.swing.JLabel Label_2;
    private javax.swing.JLabel Label_3;
    private javax.swing.JLabel Label_4;
    private javax.swing.JLabel Label_5;
    private javax.swing.JLabel Label_6;
    private javax.swing.JLabel Label_7;
    private javax.swing.JLabel Label_8;
    private javax.swing.JLabel Label_Bienvenida;
    private javax.swing.JLabel Label_Pasos;
    private javax.swing.JLabel Label_operacion;
    private javax.swing.JButton Nuevo;
    private javax.swing.JPanel Panel_trabajo;
    private javax.swing.JButton Salir;
    private javax.swing.JTextPane Text_Bienvenida;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JToolBar jToolBar1;
    // End of variables declaration//GEN-END:variables
}
